#ifndef POVMESH_H
#define POVMESH_H

#include "../../geom/Point3D.h"
#include "../../geom/Octree.h"
#include "../../geom/PolyMesh.h"

#include <QObject>

#include <string>
#include <memory>
#include <vector>

using namespace std;
using namespace geom;

namespace geom
{
	class Vector3D;
	class Triangle;
}

class AOProgressDialog;

namespace POVGeom
{
	class POVTexture;
	/** Used to load and process a mesh from a POVTree-generated file*/
	class POVMesh: public QObject
	{
		Q_OBJECT
		/** \todo unify this class with geom/PolyMesh.h, as both have the same use */
		protected:
			PolyMesh * m_mesh;
			bool mustStopAOProcessing;

			void generateNormalsForBlock(const vector<NTuple<int,3> > & trisBlock);
			Vector3D calculateNormalsAverage(const vector<Vector3D>& normals);

		signals:
			void aoPointsProcessed(int meshNum, int numTris);
			void meshFinished(int meshNum);

		public slots:
			void stopAOProcessing();
			
		public:
			POVMesh(PolyMesh * p):QObject(),m_mesh(p) {}

			void addMeshToOctree(Octree<geom::Triangle>* octree);
			void generateAmbientOcclusion(Octree<Triangle> * octree, int numRays,AOProgressDialog * progress, int thisMeshNum);
			void generateNormals();

			virtual ~POVMesh(){}
	};
};
#endif
